home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / database / msgobj10.zip / MSGOBJDT.CPP < prev    next >
C/C++ Source or Header  |  1993-02-21  |  981b  |  43 lines

  1. // MSGOBJDT.CPP: module to handle date and time in fidonet format
  2.  
  3. #include <ctype.h>
  4. #include <iostream.h>
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include "config.h"
  9. #include "msgobj.h"
  10.  
  11. #ifndef PIPVARS
  12.   static char *mname[12]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
  13. #endif
  14.  
  15. int date_time_class::parse(char*s)
  16. {
  17.   int i;
  18.   char smonth[6];
  19.   #ifdef DEBUG
  20.     cout << "Parsing date " << s << "\n";
  21.   #endif
  22.   sscanf(s,"%d %s %d %d:%d:%d",&day,smonth,&year,&hour,&minutes,&seconds);
  23.   month=0;
  24.   for (i=0; i!=12; i++) if (!stricmp(smonth,mname[i])) month=i+1;
  25.   return (month!=0);
  26. }
  27.  
  28. int date_time_class::pack(char*s)
  29. {
  30.   if(month==0) return -1;
  31.   sprintf(s,"%02d %3s %02d  %02d:%02d:%02d",day,mname[month-1],year%100,hour,minutes,seconds);
  32.   return 0;
  33. }
  34.  
  35. date_time_class::date_time_class(void)
  36. {
  37.   day=month=year=hour=minutes=seconds=0;
  38. }
  39.  
  40. date_time_class::~date_time_class(void)
  41. {
  42. }
  43.